<?php

require('pagina.php');
require('database.php');
require('auth.php');
require('core.php');

// Verifica se tem permissao
validaPermissao(3);

// Inicia cabecalho da pagina
pagina_inicio('ParkSys - Supplies');
adicionar_css('supplies.css');
pagina_head();

// Determina ordenacao
if (isset($_GET['order_by']))
	$order_by = $_GET['order_by'];
else
	$order_by = 'name';

// Mostra opcoes
echo "<ul id=opcoes>";
echo "<li class='positive'><a href='supply_new.php'><img src='img/add.png' alt=''>New item</a></li>";
echo "<li><a href='supplies.php?print=1&order_by={$order_by}' target='_blank'>" .
	"<img src='img/print.png' alt=''>Print</a></li>";
echo "<li><a href='supplies_table.php?order_by={$order_by}' target='_blank'>" .
	"<img src='img/excel.png' alt=''>Excel Table</a></li>";
echo "</ul><br><br>";

//Mostra formulario para ordenar
echo "<form id=ordenar method=GET action=supplies.php >";
echo "<label for=order_by>Order by:</label> <select id=order_by name=order_by>";
echo "<option value='name' ", ($order_by=='name'? "selected=TRUE" : ""), " >Name</option>";
echo "<option value='category' ", ($order_by=='category'? "selected=SELECTED" : ""), " >Category</option>";
echo "<option value='quantity' ", ($order_by=='quantity'? "selected=SELECTED" : ""), " >Quantity</option>";
echo "<option value='value' ", ($order_by=='value'? "selected=TRUE" : ""), " >Value</option>";
echo "</select>";
echo "  <input type=SUBMIT value=Ok name=submit />";
echo "</form>";

/* Shows supplies table */
flush();
include('supplies_table.php');

// Finaliza pagina
pagina_fim();
?>
